//
//  UIButton+ZUtilities.m
//  WeClubs
//
//  Created by Zed Link on 27/3/2017.
//  Copyright © 2017 Zed. All rights reserved.
//

#import "UIButton+ZUtilities.h"

@implementation UIButton (ZUtilities)

+ (instancetype)zButtonWithTitle:(NSString *)title fontSize:(CGFloat)size textColor:(UIColor *)color
{
    UIButton *btn = [self buttonWithType:UIButtonTypeCustom];
    
    btn.titleLabel.font = [UIFont systemFontOfSize:size];
    [btn setTitle:title forState:UIControlStateNormal];
    [btn setTitleColor:color forState:UIControlStateNormal];
    [btn sizeToFit];
    
    return btn;
}

+ (instancetype)zButtonWithTitle:(NSString *)title fontSize:(CGFloat)size textColor:(UIColor *)color imageName:(NSString *)imageName
{
    UIButton *btn = [self zButtonWithTitle:title fontSize:size textColor:color];

    UIImage *image = [UIImage imageNamed:imageName];
    NSString *desc = [NSString stringWithFormat:@"找不到与文件名\"%@\"所对应的图片", imageName];
    NSAssert(image != nil, desc);
    
    [btn setImage:image forState:UIControlStateNormal];
    
    return btn;
}

+ (instancetype)zButtonWithTitle:(NSString *)title fontSize:(CGFloat)size textColor:(UIColor *)color image:(UIImage *)image
{
    UIButton *btn = [self zButtonWithTitle:title fontSize:size textColor:color];
    [btn setImage:image forState:UIControlStateNormal];
    
    return btn;
}

@end
